﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web;
using System.Net.Mail;

namespace BLL
{
    public enum TypeAudit
    {
        View = 1,
        AddNewItem = 2,
        EditItem = 4,
        DeleteItem = 8
    }
    public static class Utils
    {
        public static bool HasPermission(TypeAudit Audit, int Permission)
        {
            if (((int)Audit & Permission) == (int)Audit)
                return true;
            return false;
        }       
    }

    public class SendMail_BLL
    {
        public void SendMailUTF8(string To, string TieuDe, string NoiDung)
        {
            SmtpClient SmtpServer = new SmtpClient();
            SmtpServer.Credentials = new System.Net.NetworkCredential("dvtien2110@gmail.com", "********");
            SmtpServer.Port = 587;
            SmtpServer.Host = "smtp.gmail.com";
            SmtpServer.EnableSsl = true;
            MailMessage mail = new MailMessage();
            String[] addr = To.Split(',');
            mail.From = new MailAddress("dvtien2110@gmail.com", "Test", System.Text.Encoding.UTF8);
            Byte i;
            for (i = 0; i < addr.Length; i++)
                mail.To.Add(addr[i]);
            mail.Subject = TieuDe;
            mail.IsBodyHtml = true;
            mail.Body = NoiDung;
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mail.ReplyTo = new MailAddress(To);
            SmtpServer.Send(mail);
        }
    }
}
